<template>
  <div class="auth">
    <!--  插槽-->
    <slot v-if="codes.includes(roleCode)"></slot>
  </div>
</template>

<script>
export default {
  name: "Auth",
  props: {
    codes: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      roleCode: "",
    }
  },
  mounted() {
    let roleJson = localStorage.getItem("role");
    if (roleJson) {
      let role = JSON.parse(roleJson);
      this.roleCode = role.code;
    }
    console.log(this.codes);
    console.log(this.roleCode);
  }
}
</script>

<style scoped>

</style>